package com.cloudspace.jindun.activity;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.view.View;

import com.cloudspace.jindun.R;
import com.cloudspace.jindun.ext.aq.AQUtility;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import io.rong.imkit.manager.AudioRecordManager;
import io.rong.imlib.model.Conversation;

/**
 * Created by zengxianhua on 17/1/25.
 */

public class MapActivity extends CustomTitleBaseActivity implements OnMapReadyCallback{
    private View rootView;

    @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_map, false);

        rootView = findViewById(R.id.root);

        MapFragment mapFragment = (MapFragment) getFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);

        AQUtility.postDelayed(new Runnable() {
            @Override
            public void run() {
                AudioRecordManager.getInstance().startRecord(rootView, Conversation.ConversationType.CHATROOM, "100");
            }
        }, 3000);
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        LatLng sydney = new LatLng(-33.867, 151.206);

        googleMap.setMyLocationEnabled(true);
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 13));

        googleMap.addMarker(new MarkerOptions()
                .title("Sydney")
                .snippet("The most populous city in Australia.")
                .position(sydney));
    }
}
